<template>
  <el-dialog title="已完成任务" append-to-body :visible.sync="showAction" width="70%">
    <!-- <div>可设置6个常用功能</div> -->
    <el-table :data="dataList">
      <el-table-column label="任务归属" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span v-if="scope.row.type != 100">{{ scope.row.belong }}</span>
          <span v-else>文件解密申请</span>
        </template>
      </el-table-column>
      <el-table-column label="任务内容" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span v-if="scope.row.type != 100">{{ progressLists[scope.row.processType] }}-待{{ progressTypes[scope.row.type] }}</span>
          <span v-else>文件解密申请-待解密</span>
        </template>
      </el-table-column>
      <el-table-column prop="qty" label="数量" width="100px"></el-table-column>
      <el-table-column sortable prop="createTime" label="完成时间"></el-table-column>
      <el-table-column label="任务结果">
        <template slot-scope="scope">
          <span class="warn_f" v-if="scope.row.processStatus == 8">待编制人员签名</span>
          <span class="warn_f" v-if="scope.row.processStatus == 0">审核中</span>
          <span class="warn_f" v-if="scope.row.processStatus == 1">评审中</span>
          <span class="warn_f" v-if="scope.row.processStatus == 2">记录责任人签名中</span>
          <span class="warn_f" v-if="scope.row.processStatus == 3">批准中</span>
          <span class="error_f" v-if="scope.row.processStatus == 4">审核未通过</span>
          <span class="error_f" v-if="scope.row.processStatus == 5">评审未通过</span>
          <span class="error_f" v-if="scope.row.processStatus == 6">批准未通过</span>
          <span class="success_f" v-if="scope.row.processStatus == 7">已完成</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="100px">
        <template slot-scope="scope">
          <el-popover placement="top-start" trigger="hover" v-if="scope.row.type == 100">
            <div>前往APP查看</div>
            <span class="main_co pointer" slot="reference">去查看</span>
          </el-popover>
          <span class="main_co pointer" v-else @click="completedgodo(scope.row)">去查看</span>
        </template>
      </el-table-column>
      <empty slot="empty" text="暂无已完成任务"></empty>
    </el-table>
    <span slot="footer" class="pub_center">
      <!-- <el-card class="pub_right"> -->
      <el-pagination
        @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
        :current-page="pageNo"
        :page-size="pageSize"
        :total="total"
        background
        layout="total, prev, pager, next, jumper"
      ></el-pagination>
      <!-- </el-card> -->
    </span>
  </el-dialog>
</template>

<script>
import { completedTaskPage } from '@/api/myapi/common';
export default {
  data() {
    return {
      showAction: false,
      pageNo: 1,
      pageSize: 10,
      total: 0,
      loading: false,
      dataList: []
    };
  },
  methods: {
    init() {
      if (this.dataList.length == 0) {
        this.completedTaskPage(1, 'star');
      } else {
        this.showAction = true;
      }
    },
    completedTaskPage(pageNo, star) {
      completedTaskPage({
        renwuType: '0',
        current: pageNo,
        size: this.pageSize
      }).then(({ data }) => {
        if (data && data.success) {
          this.dataList = data.data.records;
          this.total = data.data.total;
          if (star) this.showAction = true;
        }
      });
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageNo = val;
      this.completedTaskPage(val);
    },
    completedgodo(row) {
      this.showAction = false;
      this.$emit('onClick', row);
    }
  }
};
</script>

<style></style>
